//ServletForwardA.java
package com.ylaihui.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletForwardA extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        System.out.println("get req: " + username);

        Object key1 = req.getAttribute("key1");
        System.out.println("getAttribute: key1: " + key1);

        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/WEB-INF/code.html");
        requestDispatcher.forward(req,resp);

    }
}
